package cn.enited.devtools.apiaggregator.entity;

import cn.enited.devtools.apiaggregator.anno.QueryField;
import cn.enited.devtools.apiaggregator.repo.group.FindListGroup;
import cn.enited.devtools.apiaggregator.repo.group.FindOneGroup;
import cn.enited.devtools.apiaggregator.repo.group.FindPageGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Accessors(chain = true)
@Document("api_conf")
public class ApiAggObject extends BaseEntity {
    private static final long serialVersionUID = -6820757952131823327L;
    @QueryField(groups = {FindOneGroup.class, FindListGroup.class, FindPageGroup.class})
    private String name;
    @QueryField(groups = {FindOneGroup.class, FindListGroup.class, FindPageGroup.class})
    private Long projectId;
    @QueryField(groups = {FindOneGroup.class, FindListGroup.class, FindPageGroup.class})
    private String projectName;
    @QueryField(groups = {FindOneGroup.class, FindListGroup.class, FindPageGroup.class})
    private String description;
    @QueryField(groups = {FindOneGroup.class})
    private List<Entry> services;

    @Data
    @EqualsAndHashCode
    @ToString
    @Accessors(chain = true)
    public static class Entry implements Serializable {
        private static final long serialVersionUID = 6187134206115524585L;

        private String id;

        private String path;

        private String method;

        private String dataType;

        private Map<String, String> head;

        private Map<String, Object> data;
    }
}
